package com.ggqq.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 指定拦截的内容
 *
 * 继承WebMvcConfigurerAdapter配置，重写addInterceptors过滤设置
 * */
@Configuration  //表明是一个有效的配置类
public class WebConfig  extends WebMvcConfigurerAdapter {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/admin/**")//指定要拦截的路径，这里拦截"admin"访问路径
                .excludePathPatterns("/admin")
                .excludePathPatterns("/admin/login")
                .excludePathPatterns("/admin/toRegister")
                .excludePathPatterns("/admin/registerSuccess");//一定要加上，不然注册好了也给拦截了
    }
}
